package com.cn.dao.grzx;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.cn.conn.DataManager;
import com.cn.conn.ParamSet;
import com.cn.conn.ParamSetimpl;
import com.cn.conn.RowDatas;
import com.cn.entity.grzx_dzjj_entity;

public class grzx_dzjjDao extends DataManager {
	private RowDatas<grzx_dzjj_entity> gdd;

	public grzx_dzjjDao() {
		this.gdd = new Datasgdd();
	}
	
	public List<grzx_dzjj_entity> getInfo1(String kind){
		String sql = null;
		
		if (kind.equals("全部")) {
			sql="SELECT b.brand,cc.car_series,oi.return_address,o.total_cost,o.order_state FROM tb_order o LEFT JOIN tb_order_info oi ON o.order_info =oi.order_ident LEFT JOIN tb_car c ON oi.send_car = c.id LEFT JOIN tb_carbrand b ON c.brand = b.id LEFT JOIN tb_carconfigure cc ON c.configuration_information = cc.id";
			return queryList(sql, gdd);
		}else{
			sql="SELECT b.brand,cc.car_series,oi.return_address,o.total_cost,o.order_state FROM tb_order o LEFT JOIN tb_order_info oi ON o.order_info =oi.order_ident LEFT JOIN tb_car c ON oi.send_car = c.id LEFT JOIN tb_carbrand b ON c.brand = b.id LEFT JOIN tb_carconfigure cc ON c.configuration_information = cc.id WHERE o.order_state = ?";
			return queryList(sql, new ParamSet(kind), gdd);
		}
		
	}
	public class Datasgdd implements RowDatas<grzx_dzjj_entity> {

		@Override
		public grzx_dzjj_entity getRowData(ResultSet rs) throws SQLException {
			grzx_dzjj_entity gde = new grzx_dzjj_entity();
			 gde.setCarBrand(rs.getString(1));
			gde.setCarSeries(rs.getString(2));
			gde.setAddress(rs.getString(3));
			 gde.setTotalCost(rs.getDouble(4));
			 gde.setOrderstate(rs.getString(5));
			return gde;
		}

	}
}
